package tk.djcrazy.instantmessage.domain;

import java.util.ArrayList;
import java.util.List;

import javax.enterprise.inject.Model;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
@Entity
@Table
public class FriendGroup extends BaseBean{
	@ManyToOne(fetch=FetchType.LAZY, optional=false)
	@JoinColumn(name = "ownUser_id")
	private UserEntity ownUser;
	@ManyToMany(fetch=FetchType.LAZY)
	@JoinTable(
			joinColumns = @JoinColumn(name="friendGroup_id"),
			inverseJoinColumns = @JoinColumn(name="ownUser_id")
			)
	@Fetch(FetchMode.SUBSELECT)  
	private List<UserEntity> contentUsers = new ArrayList<UserEntity>();
	
	private String groupName;
	
	public UserEntity getOwnUser() {
		return ownUser;
	}
	public void setOwnUser(UserEntity ownUser) {
		this.ownUser = ownUser;
	}
	public List<UserEntity> getContentUsers() {
		return contentUsers;
	}
	public void setContentUsers(List<UserEntity> contentUsers) {
		this.contentUsers = contentUsers;
	}
	public String getGroupName() {
		return groupName;
	}
	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}
}
